package Day08;

public class DemoStringBuilder3 {
    public static void main(String[] args) {
        int[] arr={1,2,3};
        String s=arraytoString(arr);
        System.out.println(s);
    }
    public static String arraytoString(int[] arr){
        StringBuilder s=new StringBuilder();
        s.append("[");
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                s.append(arr[i]).append("]");
            }else {
                s.append(arr[i]).append(",");
            }
        }
        String s1=s.toString();
        return s1;
    }
}
